<template>
  <div>
    <Breadcrumb>
      <BreadcrumbItem>权限添加</BreadcrumbItem>
    </Breadcrumb>
    <Divider />
    <i-form v-ref:form-validate :model="formDate" :rules="ruleValidate" :label-width="80">
        <Form-item label="权限名称" prop="perName">
            <i-input v-model="formDate.perName" placeholder="请输入权限名称" style="width:300px"></i-input>
        </Form-item>
          <Form-item label="权限菜单" prop="menuName">
            <i-input v-model="formDate.menuName" placeholder="请输入权限菜单" style="width:300px"></i-input>
        </Form-item>
        <Form-item label="权限信息" prop="menuType">
             <i-input v-model="formDate.menuType" placeholder="请输入权限信息" style="width:300px"></i-input>
        </Form-item>
        <Form-item label="权限路径" prop="menuUrl">
            <i-input v-model="formDate.menuUrl" placeholder="请输入菜单链接" style="width:300px"></i-input>
        </Form-item>
        <Form-item label="菜单code" prop="menuCode">
            <i-input v-model="formDate.menuCode" placeholder="请输入菜单code" style="width:300px"></i-input>
        </Form-item>
        <Form-item label="源code" prop="parentCode">
            <i-input v-model="formDate.parentCode" placeholder="请输入源code" style="width:300px"></i-input>
        </Form-item>
        <Form-item label="权限信息" prop="perDesc">
            <i-input v-model="formDate.perDesc" placeholder="请输入权限信息" style="width:300px"></i-input>
        </Form-item>
        <Form-item label="权限描述" prop="ifVilid">
            <i-input v-model="formDate.ifVilid" placeholder="请输入权限信息" style="width:300px"></i-input>
        </Form-item>

        <Form-item>
            <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
            <i-button type="content" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
        </Form-item>
    </i-form>
  </div>
</template>
<script>
export default {
  data () {
    
    return {
      formDate: {
        permissionId:'',
        perName: '',
        menuName: '',
        menuType: '',
        menuUrl: '',
        menuCode: '',
        parentCode: '',
        perDesc: '',
        ifVilid:'',
      },
      ruleValidate: {
        perName: [
          { required: true, message: '权限名不能为空', trigger: 'blur' }
        ],
        menuName: [
          { required: true, message: '权限菜单不能为空', trigger: 'blur' }
        ],
        menuType: [
          { required: true, message: '权限信息不能为空', trigger: 'blur' }
        ],
        menuUrl: [
          { required: true, message: '权限连接不能为空', trigger: 'blur' }
        ],
        menuCode: [
          { required: true, message: '菜单code不能为空', trigger: 'blur' }
        ],
        parentCode: [
          { required: true, message: '权限信息不能为空', trigger: 'blur' }
        ],
        perDesc: [
          { required: true, message: '权限描述不能为空', trigger: 'blur' }
        ],
        ifVilid: [
          { required: true, message: '权限描述不能为空', trigger: 'blur' }
        ]
        


      }
    }
  },
  methods: {
//提交
    handleSubmit:function (name) {
      this.$axios.post('permission',{
       
        perName:this.formDate.perName,
        menuName:this.formDate.menuName,
        menuType:this.formDate.menuType,
        menuUrl:this.formDate.menuUrl,
        menuCode:this.formDate.menuCode,
        parentCode:this.formDate.parentCode,
        perDesc:this.formDate.perDesc,
        ifVilid:this.formDate.ifVilid,
      })
      .then(response=>{
        if(response.data.code==0){
          this.$router.push("purview"),
          alert("添加成功")
        }
      }
      )
        .catch()
    },
//重置
    handleReset (name) {
      this.$refs[name].resetFields()
    }
  }
}
</script>
